package com.avic.map.common.convertor;


import com.avic.map.common.model.enums.MapDataStatusEnums;
import com.avic.map.controller.info.MapVdmShipResourceListInfo;
import com.avic.map.controller.info.MapVdoShipResourceListInfo;
import com.avic.map.dal.model.MapShipResource;
import com.avic.map.dal.model.ShipResource;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 地图船舶资源对象转换器
 *
 * @author huangsheng
 */
public class MapShipResourceConvertor {

    public static List<MapVdmShipResourceListInfo> mapShipResourceListToMapVdmShipResourceListInfoList(List<MapShipResource> mapShipResourceList) {
        if (null != mapShipResourceList && mapShipResourceList.size() > 0) {
            List<MapVdmShipResourceListInfo> mapShipResourceListInfos = new ArrayList<>(mapShipResourceList.size());
            mapShipResourceList.forEach(mapShipResourceListVO -> {
                MapVdmShipResourceListInfo shipResourceListInfo = new MapVdmShipResourceListInfo();
                shipResourceListInfo.setShipNumber(mapShipResourceListVO.getShipNumber());
                shipResourceListInfo.setShipName(mapShipResourceListVO.getShipName());
                shipResourceListInfo.setShipState(MapDataStatusEnums.VIDM.getType());
                shipResourceListInfo.setShipStateDescribe(MapDataStatusEnums.VIDM.getDescribe());
                mapShipResourceListInfos.add(shipResourceListInfo);
            });
            return mapShipResourceListInfos;
        }
        return new ArrayList<>();
    }

    public static List<MapVdoShipResourceListInfo> shipResourceListToMapVdoShipResourceListInfoList(List<ShipResource> shipResources) {
        if (null != shipResources && shipResources.size() > 0) {
            List<MapVdoShipResourceListInfo> mapShipResourceListInfos = new ArrayList<>(shipResources.size());
            shipResources.forEach(shipResource -> {
                MapVdoShipResourceListInfo shipResourceListInfo = new MapVdoShipResourceListInfo();
                shipResourceListInfo.setShipName(shipResource.getShipName());
                shipResourceListInfo.setShipNumber(shipResource.getShipNumber());
                shipResourceListInfo.setShipState(shipResource.getShipState());

                MapDataStatusEnums mapDataStatusEnums = MapDataStatusEnums.getMapDataStatusEnumsByType(shipResource.getShipState());
                shipResourceListInfo.setShipStateDescribe(null != mapDataStatusEnums ? mapDataStatusEnums.getDescribe() : StringUtils.EMPTY);
                mapShipResourceListInfos.add(shipResourceListInfo);
            });
            return mapShipResourceListInfos;
        }
        return new ArrayList<>();
    }
}
